#pragma once
#include "iostream"
#include "cocos2d.h"

using namespace cocos2d;
using namespace std;

enum
{
	HOURSE_CARD = 0,
	MONEY_CARD = 1
};

class CardSprite : public Sprite
{
protected:
    bool init(unsigned nCardType, unsigned int nCardIndex);
	Sprite* m_pCard = nullptr;
	LayerColor* m_pBaseColor = nullptr;
	Label* m_pPrice = nullptr;
	Label* m_pSold = nullptr;

	int m_nCardType;
	int m_nCardIndex = 0;

	void turnToColor();

public:
	static CardSprite* create(unsigned nCardType, unsigned int nCardIndex);
	static string getHourseCardImage(int nHourseIndex);

	void showCard();
	void playShowAnimation();
	void showCurrentPrice(int nPrice);
	void showDealPrice(int nPrice);
	void setCardIndex(int nHoursCardIndex);
	void turnToCardBack();
	void turnToBlackWhite();

	int getCardIndex() { return m_nCardIndex; }
};

class SellCardSprite : public Sprite
{
	static bool s_bSelectLock;
	static int s_nSelectedZoder;

	bool m_bSelected = false;
	bool m_bSold = false;
	float m_flXLastTouch;

	bool init(unsigned int nCardIndex);
	bool onCardSellected(Touch* touch, Event* event);
	void onCardMovedBy(Touch* touch, Event* event);
	void onCardSellectEnded(Touch* touch, Event* event);
	void unSelected(Ref* pObj);

	int m_nZoder;
	int m_nCardIndex;

public:
	static SellCardSprite* create(unsigned int nCardIndex);

	bool isSelected() { return m_bSelected; }
	void sold();
	void playTurnBackAnimation();
	int getCardIndex() { return m_nCardIndex; }
};